
// $(".back").click(function(event) {
// 	$(this).attr('href', 'http://www.baidu.com');
// });
var take_count =parseInt( $(".count").html());
$(".take").click(function(){
	
})
var mind_count =parseInt( $(".mind").children().eq(1).html());
$(".mind").click(function(){
	// console.log($(this).children().eq(0).css("color"))
	
})


$("body").click(function(e){
	var target = e.target;

	if (target.classList[2] == "back") {
		// window.location.href='../html/find.html';
        $(target).attr("href","../find.html")
	}
	if (target.classList == "take") {
		if ($(target).html() == "已订阅") {
			$(".count").html(take_count).css("color","#666")	
			$(target).html("订阅")
		}else{
			$(".count").html(take_count+1).css("color","red")	
			$(target).html("已订阅")
		}
	}
	if (target.classList[1] == "mind") {
		if ($(target).children().eq(0).css("color") == "rgb(255, 0, 0)") {
			$(target).children().eq(0).html('&#xe602;').css("color","#000").siblings().html(mind_count)
		}else{
			$(target).children().eq(0).html('&#xe601;').css("color","red").siblings().html(mind_count + 1)
		}
	}
	if (target.classList[1] == "right") {
		$(target).toggleClass("right1");
	}
    
})

































var startx, starty;
    //获得角度
    function getAngle(angx, angy) {
        return Math.atan2(angy, angx) * 180 / Math.PI;
    };
    //根据起点终点返回方向 1向上 2向下 3向左 4向右 0未滑动
    function getDirection(startx, starty, endx, endy) {
        var angx = endx - startx;
        var angy = endy - starty;
        var result = 0;
 
        //如果滑动距离太短
        if (Math.abs(angx) < 2 && Math.abs(angy) < 2) {
            return result;
        }
 
        var angle = getAngle(angx, angy);
        if (angle >= -135 && angle <= -45) {
            result = 1;
        } else if (angle > 45 && angle < 135) {
            result = 2;
        } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
            result = 3;
        } else if (angle >= -45 && angle <= 45) {
            result = 4;
        }
 
        return result;
    }
    //手指接触屏幕
    document.addEventListener("touchstart", function(e) {
        startx = e.touches[0].pageX;
        starty = e.touches[0].pageY;
    }, false);
    //手指离开屏幕
    document.addEventListener("touchend", function(e) {
        var endx, endy;
        endx = e.changedTouches[0].pageX;
        endy = e.changedTouches[0].pageY;
        var direction = getDirection(startx, starty, endx, endy);
        switch (direction) {
            case 0:
                break;
            case 1:
            	if($(".header").offset().top > 0){
            		$(".header").addClass('qq')
            	}
                break;
            case 2:
            	if($(".header").offset().top == 0){
            		$(".header").removeClass('qq')
            	}
                break;
            case 3:
                // console.log($(".aa"));
                // window.location.href='../8.17/demo.html';
                break;
            case 4:
                 console.log("bb");
                break;
            default:
        }
    }, false);